<div class="page-block">
<?php echo $html->getTitle('cName')?> 
</div>
<div class="page">     
    <div class="Content">    
        <?php echo $html->getContent('cIntro')?>
        <div id="formpost">
        <form method="post" onsubmit="checkform(this);return false" action="/as/insertcontactus" id="formpostcontact">       
        <input type="hidden" name="opt" value="insertcontact" /> 
          <table border="0" cellspacing="5" width="100%">
            <tr>
              <td width="140" class="txth"><?php echo __("Your Name");?>: <span class="sao1">*</span></td>
              <td colspan="2">
        	  		<input name="Name" id="Name" class="tfield" />
        	  </td>
            </tr>
            <tr>
              <td class="txth"><?echo __("Your email")?>: <span class="sao1">*</span></td>
              <td colspan="2">
        			<input name="Email" id="Email" class="tfield"/>
        		</td>
            </tr>
            <tr>
              <td  class="txth"><?echo __("Subject")?>: <span class="sao1">*</span></td>
              <td colspan="2">
        	  		<input name="Subject" id="Subject" class="tfield" />
        		</td>
            </tr>
            <tr>
              <td  class="txth"><?echo __("Your Message")?>: <span class="sao1">*</span></td>
              <td colspan="2">
        	  		<textarea class="tfield" name="Message" id="Message" style="width: 440px;height:140px;"></textarea>        		
        		</td>
            </tr>
            <tr>
              <td  class="txth"><?echo __("Spam Code")?>: <span class="sao1">*</span></td>
              <td colspan="2">
        	  	    <input class="tfield" maxlength="5" style="width: 50px;" id="SpamCode" name="SpamCode" />
        	  	    <img id="imgcodespam" src="/ImgSpam/<?echo time()?>.jpg" width="100" height="20" alt="Code Spam" 
        						onclick="this.src='/ImgSpam/f'+Math.random()+'.jpg'" class="cpointer"/>
        		</td>
            </tr>	
            <tr>
              <td align="right" style="padding-top:15">&nbsp;</td>
              <td colspan="2" style="padding-top:10px">
        			<input type="submit" id="butsend" value="<?echo __("Send")?>" />
             </td>
            </tr>
          </table>  
        </form>
    </div>
    </div>
</div>
<script type="text/javascript">
function checkform(fox)
{
	if(fox.Name.value=="")
	{
		alert("<?php echo __('Please enter your name')?>!");
		fox.Name.focus();
		return false;
	}
	if(!isEmail(fox.Email.value))
	{
		alert("<?php echo __('Please enter your email')?>!");
        fox.Email.focus();
        return false;
	}	
	if(fox.Subject.value=="")
	{
		alert("<?php echo __('Please select subject')?>!");
		fox.Subject.focus();
		return false;
	}
	
	if(fox.Message.value=="")
	{
		alert("<?php echo __('Please enter Message')?>!");
		fox.Message.focus();
		return false;
	} 
	if(fox.SpamCode.value == "")
 	{
 		alert("<?php echo __('Please enter security code')?>!");		
 		fox.SpamCode.focus();
 		return false;
 	}
    jQuery.post("/as/insertcontactus",
      $("#formpostcontact").serialize(),
      function(msg){
         postsuccess(msg);
      },
      'json'
    );
    return false;
}       

function postsuccess(obj)
{
    getId('butsend').value="<?php echo __('Send')?>";
    if(obj.status=='spam')
    {
        getId('SpamCode').value='';
        getId('imgcodespam').src = '/ImgSpam/'+Math.random()+'.jpg';        
    }
    else if(obj.status=='ok')
    {
        getId('formpost').innerHTML=obj.msg;
        return;
    }
    if(obj.msg)
    {
        alert(obj.msg);
    }else
    {
        alert(obj);
    }
    
}
</script>